/**
 * Copyright 2019 Inc.
 **/
package com.myz.demo;

import feign.Feign;
import feign.Logger;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;
import feign.slf4j.Slf4jLogger;

import java.util.List;

/**
 * GsonDecoder依赖:Gson 包含了一个编码器和一个解码器，这个可以被用于JSON格式的API
 * <dependency>
 * <groupId>com.netflix.feign</groupId>
 * <artifactId>feign-slf4j</artifactId>
 * <version>8.18.0</version>
 * </dependency>
 *
 * @author maoyz0621 on 19-7-11
 * @version: v1.0
 */
public class Slf4jFeign {

    /**
     * 使用Slf4jLogger()
     *
     * @param args
     */
    public static void main(String... args) {
        GitHub github = Feign.builder()
                .encoder(new GsonEncoder())
                .decoder(new GsonDecoder())
                .logger(new Slf4jLogger())
                .logLevel(Logger.Level.FULL)
                .target(GitHub.class, "https://api.github.com");

        List<Contributor> contributors = github.contributors("OpenFeign", "feign");
        for (Contributor contributor : contributors) {
            System.out.println(contributor.login + " (" + contributor.contributions + ")");
        }
    }
}